package cn.bdqn.service.impl;

import cn.bdqn.mapper.RoleMapper;
import cn.bdqn.pojo.Role;
import cn.bdqn.service.RoleService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    RoleMapper roleMapper;

    @Override
    public List<Role> findAllRoles() {
        List<Role> lsit = roleMapper.selectList(null);
        return lsit;
    }

    @Override
    public IPage<Role> selectList(Integer pageNo, Integer pageSize, String roleName) {
        Page page=new Page(pageNo,pageSize);
        IPage iPage = roleMapper.selectLists(page, roleName);
        return iPage;
    }

    @Override
    public int insert(Role role) {
        return roleMapper.insert(role);
    }

    @Override
    public Role selectOne(Long roleId) {
        Role role = roleMapper.selectById(roleId);
        return role;
    }

    @Override
    public int update(Role role) {
        return  roleMapper.updateById(role);
    }

    @Override
    public int delete(Long id) {
        return roleMapper.deleteById(id);
    }

}
